<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>

    // var a = [1,2,3,4];
    // var b = [3,4,5,6];
    // var c = [3,4];  ? 找公共项
    // let a = [1,2,3,4];
    // let b = [3,4,5,6];

    // let arr = a.concat(b);

    
    // let c = arr.find(function (item, index, arr) {
    //         if(item+1 == item){
    //             return item;
    //         }
    // })
    //     console.log(c);


    var a = [1,2,3,4];
    var b = [3,4,5,6];
    var arr = a.concat(b);
    
    arr.sort(function(a,b){   /* 排序 */
        return a-b;
    });

    let c = [];

    for(i = 0;i < arr.length;i++){  
        if(arr[i] == arr[i+1]){  /* 如果第一个和第二个相等*/
            // arr.splice(i,1); /* 删除自身，以此类推  */
            c.push(Number(arr.splice(i,1)))
            i--; /* i-- 是为了和满足这个条件的抵消，(数组塌陷) */
        }

    }
    console.log(c);





</script>
</html>